﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MindASPCoreWebAPI.ApiLibrary.PermissionsValidation;
using MindASPCoreWebAPI.DtoModel.Common;
using MindASPCoreWebAPI.PoModel.SystemManager;
using MindASPCoreWebAPI.Service.SystemManager;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MindASPCoreWebAPI.ApiProject.Area.SystemManager
{

    //行业控制器
    [ApiModuleRelation("IndustrialManagement_manager")]
    public class IndustrialManagementController : SystemManagerBaseController
    {

        //BLL依赖注入
        private IndustrialManagementService _industrialManagementService;
        public IndustrialManagementController(IndustrialManagementService industrialManagementService)
        {
            _industrialManagementService = industrialManagementService;
        }

        //分页显示
        [HttpGet]
        public IActionResult Show_IndustryAdminModel(int pageindex, int pagesize, int? comstatus, string comname = "")
        {
            
                int totalcount = 0;

                var list = _industrialManagementService.Show_IndustryAdminModel(out totalcount,pageindex, pagesize, comstatus, comname);
                return Ok(new { list, totalcount });
           


        }


        //添加
        [HttpPost]
        public ResultModel<int> Add_IndustryAdminModel(IndustryAdminModel industryadminModel)
        {
            try
            {
                var data = _industrialManagementService.Add_IndustryAdminModel(industryadminModel);
                return MyOk(data);
            }
            catch (Exception)
            {

                throw;
            }

        }


        //删除
        [HttpDelete]
        public ResultModel<int> Delete_IndustryAdminModel(int com_id)
        {
            try
            {
                var data = _industrialManagementService.Delete_IndustryAdminModel(com_id);
                return MyOk(data);
            }
            catch (Exception)
            {

                throw;
            }
        }

        //编辑
        [HttpGet]
        public ResultModel<IndustryAdminModel> Edit_IndustryAdminModel(int com_id)
        {
            try
            {
                var data = _industrialManagementService.Edit_IndustryAdminModel(com_id);
                return MyOk(data);
            }
            catch (Exception)
            {

                throw;
            }
        }

        //修改
        [HttpPut]
        public ResultModel<int> Update_IndustryAdminModel(IndustryAdminModel industryAdminModel)
        {
            try
            {
                var data = _industrialManagementService.Update_IndustryAdminModel(industryAdminModel);
                return MyOk(data);
            }
            catch (Exception)
            {

                throw;
            }
        }


    }
}